package com.wodan.zhongjinjicang.common.orm.ibatis;

import com.wodan.zhongjinjicang.common.orm.metadata.MetaDataFactory;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
import org.springframework.util.Assert;



public class OrmObjectWrapperFactory implements ObjectWrapperFactory {

	@Override
	public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
		Assert.notNull(metaObject);
		Assert.notNull(object);
		
		return new OrmBeanWrapper(metaObject, object);
	}

	@Override
	public boolean hasWrapperFor(Object object) {
		Assert.notNull(object);
		if (!MetaDataFactory.isOrmEntity(object.getClass())) {
			return false;
		}
		
		return true;
	}
}
